package service;

public class Supermarket {
    private Apple apple;
    private Strawberry strawberry;
    private Mango mango;

    public Supermarket() {
        this.apple = new Apple(8);
        this.strawberry = new Strawberry(13);
        this.mango = new Mango(20);
    }

    // 计算顾客A购买的苹果和草莓的总价
    public double calculatePriceForCustomerA(int appleWeight, int strawberryWeight) {
        return apple.calculateTotalPrice(appleWeight) + strawberry.calculateTotalPrice(strawberryWeight);
    }

    // 计算顾客B购买的苹果、草莓和芒果的总价
    public double calculatePriceForCustomerB(int appleWeight, int strawberryWeight, int mangoWeight) {
        return apple.calculateTotalPrice(appleWeight) +
                strawberry.calculateTotalPrice(strawberryWeight) +
                mango.calculateTotalPrice(mangoWeight);
    }

    // 计算顾客C购买的苹果、草莓和芒果的总价，草莓打8折
    public double calculatePriceForCustomerC(int appleWeight, int strawberryWeight, int mangoWeight) {
        double strawberryTotalPrice = strawberry.pricePerJin * 0.8 * strawberryWeight; // 草莓打8折
        return apple.calculateTotalPrice(appleWeight) +
                strawberryTotalPrice +
                mango.calculateTotalPrice(mangoWeight);
    }

    // 计算顾客D购买的苹果、草莓和芒果的总价，并应用满100减10的促销
    public double calculatePriceForCustomerD(int appleWeight, int strawberryWeight, int mangoWeight) {
        double totalPrice = calculatePriceForCustomerC(appleWeight, strawberryWeight, mangoWeight);
        return totalPrice >= 100 ? totalPrice - 10 : totalPrice;
    }

    // 验证函数
    public static void main(String[] args) {
        Supermarket supermarket = new Supermarket();

        // 验证顾客A
        double priceA = supermarket.calculatePriceForCustomerA(5, 3);
        System.out.println("顾客A的总价: " + priceA);

        // 验证顾客B
        double priceB = supermarket.calculatePriceForCustomerB(5, 3, 2);
        System.out.println("顾客B的总价: " + priceB);

        // 验证顾客C
        double priceC = supermarket.calculatePriceForCustomerC(5, 3, 2);
        System.out.println("顾客C的总价: " + priceC);

        // 验证顾客D
        double priceD = supermarket.calculatePriceForCustomerD(5, 3, 2);
        System.out.println("顾客D的总价: " + priceD);
    }
}
